package com.fzz.learning_forum.serviceImpl;

import com.fzz.learning_forum.dao.AdminMapping;
import com.fzz.learning_forum.domain.Admin;
import com.fzz.learning_forum.domain.User;
import com.fzz.learning_forum.service.AdminService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class AdminServiceImpl implements AdminService {

    @Autowired
    private AdminMapping adminMapping;

    //管理员登录
    @Override
    public Admin adminLogin(String adminName, String password) {
        return adminMapping.adminLogin(adminName,password);
    }

    //查询所有用户
    @Override
    public PageInfo<User> selectUserWithPage(Integer page,Integer count) {

        PageHelper.startPage(page,count);
        List<User> userList = adminMapping.selectUserWithPage();
        PageInfo<User> pageInfo=new PageInfo<>(userList);
        return pageInfo;
    }

    //禁用用户
    @Override
    public Integer deleteUserById(Integer id) {
        return adminMapping.deleteUserById(id);
    }


    //授权用户
    @Override
    public Integer empowerUserById(Integer id) {
        return adminMapping.empowerUserById(id);
    }

    //禁用动态
    @Override
    public Integer deleteArticleById(Integer id) {
        return adminMapping.deleteArticleById(id);
    }

    //授权动态
    @Override
    public Integer empowerArticleById(Integer id) {
        return adminMapping.empowerArticleById(id);
    }
}
